<?php
try{
if(isset($this->categories) && count($this->categories) > 0 ){
    
        foreach($this->categories as $category){
            if(isset ($category->accessories) && count($category->accessories)> 0){
?>
<div  class="box">
      <div class="b-title">
            <div class="bt-wrapper">Phụ tùng <?php echo $category->name;?></div>
      </div>
      <div class="b-container">
      <?php
        foreach($category->accessories as $accessory){
            $arrImages = explode('@', $accessory->feature_image);

        ?>
       <div class="product">
            <a href="<?php echo $this->url(array("slug" => $accessory->slug), "post_view");?>" title="" rel="lightbox">
            <?php
            if(extension_loaded("gd") && function_exists("exec") ){
            ?>
                <img src="<?php echo PUBLIC_URL.'/plugins/phpThumb/phpThumb.php?src='.$arrImages[0].'&amp;w=145&amp;h=95'?>" alt="<?php echo $accessory->title?>"/>
            <?php }else{?>
                <img src="<?php echo $arrImages[0];?>" alt="<?php echo $accessory->title?>" width="145px" height="95px"/>
            <?php }?>

            </a>
            <div>
              <h4><a href="<?php echo $this->url(array("slug" => $accessory->slug), "post_view");?>"><?php echo $accessory->title;?></a></h4>
                                <span class="price">Giá: <?php echo number_format($accessory->price);?></span>
              <span class="hot"></span>
            </div>
        </div>
        
            <?php
                    }
                

            ?>
            <div class="readmore clearfix">
                <a href="<?php echo $this->url(array("cat_slug" => $category->slug), "accessory_view");?>">&raquo; Xem tất cả</a>
            </div>
      </div>
</div>
<?
            }
    }
}  elseif (isset($this->category) ) {
?>
<div  class="box">
      <div class="b-title">
            <div class="bt-wrapper">Phụ tùng <?php echo $this->category->name;?></div>
      </div>
      <div class="b-container">
      <?php
            if(isset ($this->accessories) && count($this->accessories)> 0){
                foreach($this->accessories as $accessory){
                    $arrImages = explode('@', $accessory->feature_image);

            ?>
        <div class="product">
            <a href="<?php echo $this->url(array("slug" => $accessory->slug), "post_view");?>" title="" rel="lightbox">
            <?php
            if(extension_loaded("gd") && function_exists("exec") ){
            ?>
                <img src="<?php echo PUBLIC_URL.'/plugins/phpThumb/phpThumb.php?src='.$arrImages[0].'&amp;w=145&amp;h=95'?>" alt="<?php echo $accessory->title?>"/>
            <?php }else{?>
                <img src="<?php echo $arrImages[0];?>" alt="<?php echo $accessory->title?>" width="145px" height="95px"/>
            <?php }?>

            </a>
            <div>
              <h4><a href="<?php echo $this->url(array("slug" => $accessory->slug), "post_view");?>"><?php echo $accessory->title;?></a></h4>
                                <span class="price">Giá: <?php echo number_format($accessory->price);?></span>
              <span class="hot"></span>
            </div>
        </div>
                        <?php
                                }
                            }
                        
                        ?>
            <div class=" clearfix">
                
            </div>
      </div>
</div>


<?php
echo $this->paginationControl($this->accessories,
                                    'Sliding',
                                    'category/apagination.phtml', array('category' => $this->category));
}
 }  catch (Exception $ex){
                            echo $ex->getMessage();
                        }
?>